<?php

namespace app\admin\validate;

use think\Validate;

class Category extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require|length:2,20',
        'sort' => 'require|integer|between:0,99',
        'type' => 'require|integer',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'name.require' => '分类名称必须',
        'name.length' => '分类名称长度只能在2-20个字符之间',
        'sort.require' => '排序不能为空',
        'sort.integer' => '排序只能输入整数类型',
        'sort.between' => '排序只能在0-99之间',
        'type.require' => '类型必须',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name','sort','type'],
        'edit' => ['name','sort','type'],
    ];
}
